package com.zhousb.deviceManager.controller;

import cn.hutool.json.JSONObject;
import com.zhousb.deviceManager.common.R;
import com.zhousb.deviceManager.common.ResponseResult;
import com.zhousb.deviceManager.model.vo.AuthVo;
import com.zhousb.deviceManager.model.dto.LoginDto;
import com.zhousb.deviceManager.service.LoginService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth")
@Tag(name = "用户认证")
public class AuthController {

    @Resource
    LoginService loginService;

    @PostMapping("/login")
    public ResponseResult<AuthVo> login(@RequestBody LoginDto dto) {
        return R.success(loginService.login(dto));
    }

    @GetMapping("/tempLogin")
    public ResponseResult<AuthVo> tempLogin(@Param("phone")String phone) {
        return R.success(loginService.tempLogin(phone));
    }

    @GetMapping("/wxCode")
    public ResponseResult getWxCode (){
        JSONObject jsonObject = new JSONObject();
        jsonObject.set("session_key","2nQpY3nZIOgsL++v372FJQ==");
        jsonObject.set("openid","ohfTi5ereCjwsCzYLSbObZQlCC7g");
        return R.success(jsonObject);
    }
}
